package com.tianhui.consignortwofei.mvp.model;

import android.content.Context;

import com.fgs.common.CommonModel;
import com.fgs.common.api.CommonConfig;
import com.fgs.common.progress.ObserverResponseListener;
import com.tianhui.consignortwofei.api.OrderApiService;
import com.tianhui.consignortwofei.mvp.model.enty.FreightCalculationInfo;
import com.tianhui.consignortwofei.mvp.model.enty.GoodsInfo;
import com.tianhui.consignortwofei.mvp.model.enty.HeDanListBean;

import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import io.reactivex.ObservableTransformer;

/**
 * @author fgs
 * @date 2020/8/27
 * @description
 **/
public class OrderModel<T> extends CommonModel<T> implements IDictionaryModel<T> {


    /**
     * 订单列表
     *
     * @param context
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void orderListModel(Context context, Observable observable, boolean isDialog,
                               ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, observable, observerListener, transformer, isDialog, true);
    }

    /**
     * 订单详情
     *
     * @param context
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void orderDetailModel(Context context, Observable observable, boolean isDialog,
                                 ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, observable, observerListener, transformer, isDialog, true);
    }

    @Override
    public void dictionaryModel(Context context, Map<String, String> map, boolean isDialog, ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {
        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).dictionaryList(map), observerListener, transformer, isDialog, true);
    }

    /**
     * 车长吨位列表
     *
     * @param context
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void vehicleLimitListModel(Context context, boolean isDialog,
                                      ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).vehicleLimitList(), observerListener, transformer, isDialog, true);
    }

    /**
     * 发布货源
     *
     * @param context
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void publishSourceModel(Context context, GoodsInfo info, boolean isDialog,
                                   ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        //当不需要指定是否由dialog时，可以调用这个方法
        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).publishSource(info), observerListener, transformer, isDialog, true);
    }

    /**
     * 发布询价货源
     *
     * @param context
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void publishInquirySourceModel(Context context, GoodsInfo info, boolean isDialog,
                                          ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        //当不需要指定是否由dialog时，可以调用这个方法
        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).publishInquirySource(info), observerListener, transformer, isDialog, true);
    }

    /**
     * 发布询价货源
     *
     * @param context
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void publishLiteSourceModel(Context context, GoodsInfo info, boolean isDialog,
                                       ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        //当不需要指定是否由dialog时，可以调用这个方法
        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).publishLiteSource(info), observerListener, transformer, isDialog, true);
    }

    /**
     * 司机信息
     *
     * @param context
     * @param map
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void driverInfoModel(Context context, Map<String, String> map, boolean isDialog,
                                ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).driverInfo(map), observerListener, transformer, isDialog, true);
    }

    /**
     * 调度明细列表
     *
     * @param context
     * @param map
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void dispatchDetailListModel(Context context, Map<String, String> map, boolean isDialog,
                                        ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).dispatchDetailList(map), observerListener, transformer, isDialog, true);
    }

    /**
     * 货源明细列表
     *
     * @param context
     * @param map
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void sourceDetailListModel(Context context, Map<String, String> map, boolean isDialog,
                                      ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).sourceDetailList(map), observerListener, transformer, isDialog, true);
    }










    /**
     * 运费计算
     *
     * @param context
     * @param info
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void freightModel(Context context, FreightCalculationInfo info, boolean isDialog,
                             ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).freightCalculation(info), observerListener, transformer, isDialog, true);
    }

    /**
     * 撤销运费计算
     *
     * @param context
     * @param map
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void insureQueryModel(Context context, Map<String, String> map, boolean isDialog,
                                 ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).revokeFreightCalculation(map), observerListener, transformer, isDialog, true);
    }

    /**
     * 车辆轨迹
     *
     * @param context
     * @param map
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void vehicleTrajectoryModel(Context context, Map<String, String> map, boolean isDialog,
                                       ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).vehicleTrajectory(map), observerListener, transformer, isDialog, true);
    }

    /**
     * 车辆位置
     *
     * @param context
     * @param map
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void vehicleLocationModel(Context context, Map<String, String> map, boolean isDialog,
                                     ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).vehicleLocation(map), observerListener, transformer, isDialog, true);
    }

    /**
     * 货源单详情
     *
     * @param context
     * @param map
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void orderDetailModel(Context context, Map<String, String> map, boolean isDialog,
                                 ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).orderDetail(map), observerListener, transformer, isDialog, true);
    }

    /**
     * 销售员列表
     *
     * @param context
     * @param map
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void salesManListModel(Context context, Map<String, String> map, boolean isDialog,
                                  ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).salesManList(map), observerListener, transformer, isDialog, true);
    }


    /**
     * 订单详情
     *
     * @param context
     * @param map
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void orderSourceInfoModel(Context context, Map<String, String> map, boolean isDialog,
                                     ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).dispatchDetail(map), observerListener, transformer, isDialog, true);
    }

    /**
     * 调整运单图片信息
     *
     * @param context
     * @param map
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void confirmLoadingChangePictureModel(Context context, Map<String, String> map, boolean isDialog,
                                                 ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).confirmLoadingChangePicture(map), observerListener, transformer, isDialog, true);
    }

    /**
     * 调整运单图片信息
     *
     * @param context
     * @param map
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void updateOrderPictureModel(Context context, Map<String, String> map, boolean isDialog,
                                                 ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).updateOrderPicture(map), observerListener, transformer, isDialog, true);
    }



    /**
     * 转延长
     *
     * @param context
     * @param map
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void zhuanYanChang(Context context, Map<String, String> map, boolean isDialog, ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {
        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).zhuanYanChang(map), observerListener, transformer, isDialog, true);
    }


    /**
     * 确认取消单子
     *
     * @param context
     * @param map
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void queRenDingDan(Context context, Map<String, String> map, boolean isDialog, ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {
        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).queRenDingDan(map), observerListener, transformer, isDialog, true);
    }




    /**
     * 获取合单列表
     *
     * @param context
     * @param isDialog
     * @param transformer
     * @param observerListener
     */

    public void getHeDanList(Context context, Map<String, String> map, boolean isDialog, ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {
        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).getHeDanList(map), observerListener, transformer, isDialog, true);
    }

    /**
     * 提交合单列表
     *
     * @param context
     * @param isDialog
     * @param transformer
     * @param observerListener
     */

    public void sendHeDanTrue(Context context, List<HeDanListBean> allData, boolean isDialog, ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {
        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).sendHeDanTrue(allData), observerListener, transformer, isDialog, true);
    }



    /**
     * 合单删除
     *
     * @param context
     * @param isDialog
     * @param transformer
     * @param observerListener
     */

    public void heDanDelete(Context context, Map<String, String> map, boolean isDialog, ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {
        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).heDanDelete(map), observerListener, transformer, isDialog, true);
    }





//    /**
//     * 货源单列表
//     *
//     * @param context
//     * @param map
//     * @param isDialog
//     * @param transformer
//     * @param observerListener
//     */
//    public void sourceListModel(Context context, Map<String, String> map, boolean isDialog,
//                                ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {
//
//        subscribe(context, Api.getApiService().sourceList(map), observerListener, transformer, isDialog, true);
//    }
//
//    /**
//     * 调度单列表
//     *
//     * @param context
//     * @param map
//     * @param isDialog
//     * @param transformer
//     * @param observerListener
//     */
//    public void dispatchListModel(Context context, Map<String, String> map, boolean isDialog,
//                                  ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {
//
//        subscribe(context, Api.getApiService().dispatchList(map), observerListener, transformer, isDialog, true);
//    }



    /**
     * app车辆轨迹
     *
     * @param context
     * @param map
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void getAppTrajectory(Context context, Map<String, String> map, boolean isDialog,
                                       ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).getAppTrajectory(map), observerListener, transformer, isDialog, true);
    }




    /**
     * 获取牌号
     *
     * @param context
     * @param map
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void getPaiHaoType(Context context, Map<String, String> map, boolean isDialog, ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {
        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).getPaiHaoType(map), observerListener, transformer, isDialog, true);
    }


    /**
     * 修改单个牌号
     *
     * @param context
     * @param info
     * @param isDialog
     * @param transformer
     * @param observerListener
     */
    public void savePaiHaoDangQian(Context context, QuotationListBean.QuotationRecords.PlasticsQuotationListDTO info, boolean isDialog,
                             ObservableTransformer<T, T> transformer, ObserverResponseListener observerListener) {

        subscribe(context, CommonConfig.getInstance().create(OrderApiService.class).savePaiHaoDangQian(info), observerListener, transformer, isDialog, true);
    }






}
